package graph.geometricshapes
{
	import mx.messaging.AbstractConsumer;
	
	public class GeometricEllipse extends GeometricShape
	{
		public override function get getName():String
		{
			return NAME;
		}
		
		public static const NAME:String = "GeometricEllipse";
		
		public static const DefaultXSide:Number = 50;
		public static const DefaultYSide:Number = 25;
		
		
		public function get a():Number
		{
			var result:Number = this.width / 2;
			return result;
		}
		
		public override function set width(value:Number):void
		{
			/* if (value < 0)
			{
				throw new ArgumentError("Error while setting " + this.getName + " width value ( " + value.toString() + " )!");
			} */
			this._width = value;
		}
		
		public function get b():Number
		{
			var result:Number = this.height / 2;
			return result;
		}
		
		public override function set height(value:Number):void
		{
			/* if (value < 0)
			{
				throw new ArgumentError("Error while setting " + this.getName + " height value ( " + value.toString() + " )!");
			} */
			this._height = value;
		}
		
		public function GeometricEllipse(width:Number = DefaultXSide, height:Number = DefaultYSide)
		{
			super(width, height);
		}
		
		public override function getArea():Number
		{
			var result:Number = a * b * Math.PI;
			return result;
		}
		
		public override function getPerimeter():Number
		{
			// perimeter due to Ramanujan, second approximation
			var h:Number = ((a-b)*(a-b))/((a+b)*(a+b));
			var result:Number = Math.PI * (a + b) * ( (1 + 3*h) / (10 + ((4 - 3*h)*0.5) ) );
			return result;
		}
	}
}